﻿using System.Web.Mvc;
using System.Web.Routing;
using Azure.Online.Web.Controllers;
using Azure.Online.Web.Routing;

namespace Azure.Online.Web {
    public class RouteConfig {
        public static void RegisterRoutes(RouteCollection routes) {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute("api.root", "api", new { controller = "EmptyApi", action = "None" });

            routes.MapWebRoute<ProxyController>("proxy.get", "proxy/", new { action = "ExecuteGet" }, null, "GET");
            routes.MapWebRoute<ProxyController>("proxy.put", "proxy/", new { action = "ExecutePut" }, null, "PUT");
            routes.MapWebRoute<ProxyController>("proxy.post", "proxy/", new { action = "ExecutePost" }, null, "POST");
            routes.MapWebRoute<ProxyController>("proxy.delete", "proxy/", new { action = "ExecuteDelete" }, null, "DELETE");

            routes.MapWebRoute<ProxyController>("proxy.download", "proxy-download/{id}", new { action = "ExecuteDownload" }, null, "GET");
            routes.MapWebRoute<ProxyController>("proxy.download.new", "proxy/download/", new { action = "Download" }, null, "GET");

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}